package com.qzsf.backend.mapper.sql;

import org.apache.ibatis.jdbc.SQL;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/24 21:58 周日
 * @Email 1429278462@qq.com
 * @Remark 用户反馈多条件查询
 * @Version 1.0
 */
public class FeedbackSqlProvider {
    public String getFeedbackByCondition(Integer typeId,Integer eventId) {
        return new SQL() {{
            SELECT("a.user_id as userId,c.name as userName,a.content, a.rating, a.created_at as createdAt, b.name AS eventName");
            FROM("feedback a");
            LEFT_OUTER_JOIN("event b ON a.event_id = b.id");
            LEFT_OUTER_JOIN("user_profile c on a.user_id = c.id");

            if (typeId != null) {
                WHERE("b.typeId = #{typeId}");
            }
            if (eventId != null){
                WHERE("b.id = #{eventId}");
            }
        }}.toString();
    }
}
